import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs))
}

/**
 * 根据总分获取称号和图标
 * @param score 玩家总分
 * @returns 包含称号名称、颜色、图标和描述的对象
 */
export function getTitleByScore(score: number): { name: string; color: string; icon: string; description: string } {
  if (score >= 250) {
    return { 
      name: '战神', 
      color: '#FF4500', 
      icon: 'https://mctiers.com/titles/combat_master.webp',
      description: '总分250+: 战神'
    };
  } else if (score >= 100) {
    return { 
      name: '战王', 
      color: '#FFD700', 
      icon: 'https://mctiers.com/titles/combat_ace.webp',
      description: '总分100+: 战王'
    };
  } else if (score >= 50) {
    return { 
      name: '战斗精英', 
      color: '#00BFFF', 
      icon: 'https://mctiers.com/titles/combat_specialist.svg',
      description: '总分50+: 战斗精英'
    };
  } else if (score >= 20) {
    return { 
      name: '战斗学员', 
      color: '#32CD32', 
      icon: 'https://mctiers.com/titles/combat_cadet.svg',
      description: '总分20+: 战斗学员'
    };
  } else if (score >= 10) {
    return { 
      name: '战斗新手',
      color: '#A9A9A9', 
      icon: 'https://mctiers.com/titles/combat_novice.svg',
      description: '总分10+: 战斗新手'
    };
  } else {
    return { 
      name: '菜鸟', 
      color: '#808080', 
      icon: 'https://mctiers.com/titles/rookie.svg',
      description: '总分10以下: 菜鸟'
    };
  }
}
